<div>
    <h2 id="page-heading">
        <span jhiTranslate="husenApp.goods.home.title">Goods</span>
        <button id="jh-create-entity" class="btn btn-primary float-right jh-create-entity create-goods" [routerLink]="['/goods/new']">
            <fa-icon [icon]="'plus'"></fa-icon>
            <span class="hidden-sm-down"  jhiTranslate="husenApp.goods.home.createLabel">
            Create new Goods
            </span>
        </button>
    </h2>
    <jhi-alert></jhi-alert>
    <div class="row">
        <div class="col-sm-12">
            <form name="searchForm" class="form-inline">
                <div class="input-group w-100 mt-3">
                    <input type="text" class="form-control" [(ngModel)]="currentSearch" id="currentSearch" name="currentSearch" placeholder="{{ 'husenApp.goods.home.search' | translate }}">
                    <button class="input-group-append btn btn-info" (click)="search(currentSearch)">
                        <fa-icon [icon]="'search'"></fa-icon>
                    </button>
                    <button class="input-group-append btn btn-danger" (click)="clear()" *ngIf="currentSearch">
                        <fa-icon [icon]="'trash-alt'"></fa-icon>
                    </button>
                </div>
            </form>
        </div>
    </div>
    <br/>
    <div class="table-responsive" *ngIf="goods">
        <table class="table table-striped">
            <thead>
            <tr jhiSort [(predicate)]="predicate" [(ascending)]="reverse" [callback]="transition.bind(this)">
            <th jhiSortBy="id"><span jhiTranslate="global.field.id">ID</span> <fa-icon [icon]="'sort'"></fa-icon></th>
            <th jhiSortBy="name"><span jhiTranslate="husenApp.goods.name">Name</span> <fa-icon [icon]="'sort'"></fa-icon></th>
            <th jhiSortBy="picImg"><span jhiTranslate="husenApp.goods.picImg">Pic Img</span> <fa-icon [icon]="'sort'"></fa-icon></th>
            <th jhiSortBy="miniPrice"><span jhiTranslate="husenApp.goods.miniPrice">Mini Price</span> <fa-icon [icon]="'sort'"></fa-icon></th>
            <th jhiSortBy="orders"><span jhiTranslate="husenApp.goods.orders">Orders</span> <fa-icon [icon]="'sort'"></fa-icon></th>
            <th jhiSortBy="status"><span jhiTranslate="husenApp.goods.status">Status</span> <fa-icon [icon]="'sort'"></fa-icon></th>
            <th jhiSortBy="shopId"><span jhiTranslate="husenApp.goods.shop">Shop</span> <fa-icon [icon]="'sort'"></fa-icon></th>
            <th></th>
            </tr>
            </thead>
            <tbody>
            <tr *ngFor="let goods of goods ;trackBy: trackId">
                <td><a [routerLink]="['/goods', goods.id, 'view' ]">{{goods.id}}</a></td>
                <td>{{goods.name}}</td>
                <td>
                    <a *ngIf="goods.picImg" (click)="openFile(goods.picImgContentType, goods.picImg)">
                        <img [src]="goods.pic" style="max-height: 30px;" alt="goods image"/>
                    </a>
                </td>
                <td>{{goods.miniPrice}}</td>
                <td>{{goods.orders}}</td>
                <td jhiTranslate="{{'husenApp.GoodsStatus.' + goods.status}}">{{goods.status}}</td>
                <td>
                    <div *ngIf="goods.shopId">
                        <a [routerLink]="['../shop', goods.shopId , 'view' ]" >{{goods.shopId}}</a>
                    </div>
                </td>
                <td class="text-right">
                    <div class="btn-group flex-btn-group-container">
                        <button type="submit"
                                [routerLink]="['/goods', goods.id, 'view' ]"
                                class="btn btn-info btn-sm">
                            <fa-icon [icon]="'eye'"></fa-icon>
                            <span class="d-none d-md-inline" jhiTranslate="entity.action.view">View</span>
                        </button>
                        <button type="submit"
                                [routerLink]="['/goods', goods.id, 'edit']"
                                class="btn btn-primary btn-sm">
                            <fa-icon [icon]="'pencil-alt'"></fa-icon>
                            <span class="d-none d-md-inline" jhiTranslate="entity.action.edit">Edit</span>
                        </button>
                        <button type="submit"
                                [routerLink]="['/', { outlets: { popup: 'goods/'+ goods.id + '/delete'} }]"
                                replaceUrl="true"
                                queryParamsHandling="merge"
                                class="btn btn-danger btn-sm">
                            <fa-icon [icon]="'times'"></fa-icon>
                            <span class="d-none d-md-inline" jhiTranslate="entity.action.delete">Delete</span>
                        </button>
                    </div>
                </td>
            </tr>
            </tbody>
        </table>
    </div>
    <div *ngIf="goods && goods.length">
        <div class="row justify-content-center">
            <jhi-item-count [page]="page" [total]="queryCount" [maxSize]="5" [itemsPerPage]="itemsPerPage"></jhi-item-count>
        </div>
        <div class="row justify-content-center">
            <ngb-pagination [collectionSize]="totalItems" [(page)]="page" [pageSize]="itemsPerPage" [maxSize]="5" [rotate]="true" [boundaryLinks]="true" (pageChange)="loadPage(page)"></ngb-pagination>
        </div>
    </div>
</div>
